package com.liang.lamda;

/**
 * @Author:liangli
 * @Date:2020/11/17 15:00
 */

/**
 * 推导lambda表达式
 */
public class TestLambda1 {

    //3.静态内部类
   static class Like1 implements ILike{
        public void lambda() {
            System.out.println("i like lambda o");
        }
    }

    public static void main(String[] args) {

        ILike like=new Like();
        like.lambda();

        Like1 like1=new Like1();
        like1.lambda();
        //4.局部内部类
        class Like2 implements ILike{
            public void lambda() {
                System.out.println("i like lambda 2");
            }
        }
        like=new Like2();
        like.lambda();
        //5.匿名内部类 没有类名 必须借助接口或者父类
        like=new ILike() {
            public void lambda() {
                System.out.println(" i like 4");
            }
        };
        like.lambda();

        //6.用lambda简化
        like=()->{
            System.out.println("i like 5");
        };
        like.lambda();
    }

}
//1.定义一个函数时接口
interface ILike{
    void lambda();
}

//2.定义实现类
class Like implements ILike{
    public void lambda() {
        System.out.println("i like lambda");
    }
}